#include "file_io.h"

using namespace std;

void read_file(std::string file_name, std::vector< std::vector<double> > &v1)
{
	static bool first_line_flag = true;
	ifstream file_in(file_name.c_str());
	
	if(file_in.is_open())
	{
		string sl;
		if( getline(file_in,sl))  { }
		
		double d[10];
		double begin_time;
		while(getline(file_in,sl))
		{
			sscanf(sl.c_str(),"%lf ,%lf ,%lf ,%lf ,%lf ,%lf ,%lf ,%lf ,%lf ,%lf",
						&d[0],&d[1],&d[2],&d[3],&d[4],&d[5],&d[6],&d[7],&d[8],&d[9]);
			if(first_line_flag)
			{
				first_line_flag = false;
				begin_time = d[2];
			}
			else
			{
				d[2] -= begin_time;
				d[2] *= 1e-5;
				
				d[3] *= Gravity;
				d[4] *= Gravity;
				d[5] *= Gravity;
				
				d[6] *= DEG;
				d[7] *= DEG;
				d[8] *= DEG;
				
				vector<double> vec_temp(d+2,d+10);
				v1.push_back(vec_temp);
			}
			/*		
			for(int i=0;i<10;i++)
				cout << d[i] << "\t";
			cout << endl;
			*/
		}
	}
	else
	{
		cout << "open file " << file_name << " failed" << endl;
	}
}
	
